
require('./common/runtime.js')
require('./common/vendor.js')
require('./common/main.js')
App({
	onLaunch: function () {
    //调用API从本地缓存中获取数据
    this.login();
  },
  login:function() {
    var that = this;
      wx.login({
        success: function(res){
          console.log(res);
          wx.getUserInfo({
            success: function(res){
              
            }
          })
        }
      })
  },


  decode:function(encryptedData, signature, iv) {
      encryptedData = atob(encryptedData);
      signature = atob(signature);
      console.log(encryptedData);
      console.log(signature);
  },
  getUserInfo:function(cb){
    var that = this
    if(this.globalData.userInfo){
      typeof cb == "function" && cb(this.globalData.userInfo)
    }else{
      //调用登录接口
      wx.login({
        success: function () {
          wx.getUserInfo({
            success: function (res) {
              console.log(res);
              that.globalData.userInfo = res.userInfo
              typeof cb == "function" && cb(that.globalData.userInfo)
            }
          })
        }
      })
    }
  },
  globalData: {//定义全局变量
    userInfo:null,
		oldman:null,
	id:null,
	address:null,
	data: {
		  latitude: 29.40268, //中心点
		  longitude: 106.54041,//中心点
		  markers:[
			  {
				  id: 0,
				  latitude: 29.40268, //初始位置
			  	  longitude: 106.54041,//初始位置
				  iconPath:"/static/icon/point.png",
				  width:30,
				  height:35,
				  callout:{
				  	content:"您当前的位置",
				  	fontSize:13,
				  	borderRadius:5,
				  	borderWidth:1,
				  	padding:2,
				  	display:"BYCLICK"
				  }
			  },
			  
			  {		
				  id: 1,
				  latitude: 29.385396966, 
				  longitude: 106.515959483,//"乔鹤养老院"
				  iconPath:"/static/icon/point.png",
				  width:30,
				  height:35,
				  callout:{
				  	content:"乔鹤养老院",
				  	fontSize:13,
				  	borderRadius:5,
				  	borderWidth:1,
				  	padding:2,
				  	display:"BYCLICK"
				  }
			  },
			  {
			  		id: 2,
					latitude: 29.408994, 
					longitude: 106.553443,//"狮子山老年公寓"
					iconPath:"/static/icon/point.png",
					width:30,
					height:35,
					callout:{
						content:"狮子山老年公寓",
						fontSize:13,
						borderRadius:5,
						borderWidth:1,
						padding:2,
						display:"BYCLICK"
					}
			  },
			  {
			  		id: 3,
					latitude: 29.427551, 
					longitude: 106.56582,//"小泉养老公寓"
			  		iconPath:"/static/icon/point.png",
			  		width:30,
			  		height:35,
					callout:{
						content:"小泉养老公寓",
						fontSize:13,
						borderRadius:5,
						borderWidth:1,
						padding:2,
						display:"BYCLICK"
					}
			  },
			  {
			  		id: 4,
					latitude: 29.374510809,
					longitude: 106.692200405,//"南彭敬老院"
			  		iconPath:"/static/icon/point.png",
			  		width:30,
			  		height:35,
					callout:{
						content:"南彭敬老院",
						fontSize:13,
						borderRadius:5,
						borderWidth:1,
						padding:2,
						display:"BYCLICK"
					}
			  },
			  {
			  		id: 5,
					latitude: 29.296250809,
					 longitude: 106.512470405,//"重庆市巴南区快乐养老院"
			  		iconPath:"/static/icon/point.png",
			  		width:30,
			  		height:35,
					callout:{
						content:"重庆市巴南区快乐养老院",
						fontSize:13,
						borderRadius:5,
						borderWidth:1,
						padding:2,
						display:"BYCLICK"
					}
			  },
		  ]
	
	}
  }
})